<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<ul id="list">
</ul>

<script>
    const list = document.getElementById('list')

    // 文档碎片(保存在内存中)
    const fragment = document.createDocumentFragment()

    for (let i = 0; i < 5; i++) {
        let item = document.createElement('li')
        item.innerHTML = `项目${i}`
        // list.appendChild(item)
        fragment.appendChild(item)
    }

    list.appendChild(fragment)  //  只有1次

</script>
</body>
</html>
